/*
 * @author dumeng
 */
'use strict'
import { BasicOption } from './basicops'
import { DataOption } from './dataops'
import { bgImgColor } from './bgImgColor'
import swiper4smallimgCard from '@/components/CustomPage/apps/widget/card/swiper4smallimgCard'
import cardComp from '@/components/CustomPage/apps/widget/card/cardComp'
import cardSwiperOne from '@/components/CustomPage/apps/widget/card/cardSwiperOne'
import cardSwiperTwo from '@/components/CustomPage/apps/widget/card/cardSwiperTwo'
import cardSwiperThree from '@/components/CustomPage/apps/widget/card/cardSwiperThree'
import cardSwiperTextImgOne from '@/components/CustomPage/apps/widget/card/cardSwiperTextImgOne'
import cardSwiperTextImgTwo from '@/components/CustomPage/apps/widget/card/cardSwiperTextImgTwo'
import {
  Area,
  Color,
  Extend,
  Input,
  Link,
  Mapping,
  Radio,
  Select, SelectGroup4var,
  Slider,
  Switch,
  UploadImage
} from '@/components/CustomPage/fields/widget'
import { cellTitleOps } from '@/components/CustomPage/apps/map/cellTitleops'
import { moreLinkOps } from '@/components/CustomPage/apps/map/moreLinkops'
import { resourcesOptions } from '@/components/CustomPage/apps/map/resourcesOps'
import { imgOption } from '@/components/CustomPage/apps/map/imgops'
import { swiperOption, swiperNoIndicatorsOption } from '@/components/CustomPage/apps/map/swiperOps'
import { labelOptions } from '@/components/CustomPage/apps/map/labelOps'
import { sourceOption } from '@/components/CustomPage/apps/map/source'
import { smallSwiperMulOptions, smallSwiperSingleOptions } from '@/components/CustomPage/apps/map/smallSwiperOps'
import { deepClone } from '@/utils'

export default {
  /**
     * 卡片组件-小图卡片轮播
     */
  swiper4smallimgCard() {
    return {
      target: swiper4smallimgCard,
      parameter: {
        relate: false,
        mold: 'field',
        label: '小图卡片轮播',
        value: []
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            ...sourceOption(),
            ...cellTitleOps(),
            // { type: Input, option: { label: '标题名称', name: 'title', required: true }},
            { type: Slider, option: { label: '下间距', name: 'bottom', value: 0, max: 100, step: 1 }},
            // { type: Slider, option: { label: '底部内间距', name: 'paddingBottom', value: 0, max: 100, step: 1 }},
            { type: Slider, option: { label: '上内间距', name: 'paddingTop', value: 0, max: 100, step: 1 }},
            { type: Slider, option: { label: '左右间距', name: 'spacing', value: 0, max: 100, step: 1 }},
            // { type: Slider, option: { label: '圆角大小', name: 'radiusSize', value: 20, max: 45, step: 1 }},
            { type: Slider, option: { label: '图片圆角大小', name: 'imgRadiusSize', value: 16, max: 100, step: 1 }},
            { type: Slider, option: { label: '列表高度', name: 'itemHeight', value: 134, max: 200, step: 1 }},
            {
              type: Color,
              option: { label: '背景颜色', name: 'backgroundColorC', value: '#fff', showalpha: true }
            },
            {
              type: Slider,
              option: {
                label: '每列展示数量',
                name: 'pageSize',
                unit: 'number',
                value: 3,
                max: 10,
                min: 2,
                step: 1
              }
            },
            {
              type: Slider, option: {
                label: '列数', name: 'column', unit: 'number', value: 3, max: 10, min: 2, step: 1
              }
            },
            {
              type: Switch,
              option: {
                label: '每屏数据分类是否一致',
                name: 'classifyFit',
                value: true,
                activetext: '是',
                inactivetext: '否'
              }
            },
            {
              type: Switch,
              option: {
                label: '是否单独设置每屏样式',
                name: 'isSingleSetting',
                value: false,
                activetext: '是',
                inactivetext: '否',
                override: function(ths, e) {
                  ths.$nextTick(() => {
                    for (let i = 0; i < ths.$parent.$parent.$children.length; i++) {
                      const name = ths.$parent.$parent.$children[i].option.name
                      if (name === 'mulPageInfo') {
                        ths.$parent.$parent.$children[i].visible = e
                      } else if (name === 'unifyPageInfo') {
                        ths.$parent.$parent.$children[i].visible = !e
                      }
                    }
                  })
                }
              }
            },

            ...smallSwiperMulOptions(),
            ...smallSwiperSingleOptions(),

            // ...moreLinkOps(),
            {
              type: Select,
              option: {
                label: '资源类型',
                name: 'resource',
                list: [
                  { name: '活动', value: 'hd' },
                  { name: '人物（劳模工匠）', value: 'lmgj' },
                  { name: '人物（大师）', value: 'ds' },
                  { name: '人物（讲师）', value: 'js' },
                  { name: '新闻', value: 'xw' },
                  { name: '直播', value: 'zb' },
                  { name: '闯关', value: 'cg' },
                  { name: '专区', value: 'zq' },
                  { name: '视频', value: 'sp' }
                ],
                value: 'hd',
                override: function(ths, e) {
                  ths.$nextTick(() => {
                    for (let i = 0; i < ths.$parent.$parent.$children.length; i++) {
                      if (ths.$parent.$parent.$children[i].option.name === 'ActivityLabel') {
                        ths.$parent.$parent.$children[i].visible = e === 'hd' || e === 'zb'
                      }
                    }
                  })
                }
              }
            },
            ...labelOptions(),
            {
              type: Mapping,
              option: {
                label: '',
                name: 'mapping',
                list: [
                  { name: '封面', code: 'imgId', value: '' },
                  { name: 'oss封面', code: 'imgUrl', value: '' },
                  { name: '标题', code: 'title', value: '' },
                  { name: '副标题', code: 'subTitle', value: '' },
                  { name: 'id', code: 'id', value: '' }
                ]
              }
            }
          ]
        },
        ...DataOption()
      ]
    }
  },
  /**
     * 横版卡片（单张）
     * @constructor
     */
  cardComp() {
    return {
      target: cardComp,
      parameter: {
        relate: true,
        mold: 'field',
        label: '横版卡片（单张）'
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            { type: Slider, option: { label: '左右间距', name: 'spacing', value: 0, max: 100, step: 1 }},
            ...cellTitleOps(),
            ...swiperNoIndicatorsOption(),
            {
              type: Radio,
              option: {
                label: '是否循环',
                name: 'loop',
                list: [{ name: '是', value: true }, { name: '否', value: false }],
                value: true
              }
            },
            {
              type: Slider,
              option: { label: '图片高度', name: 'imgHeight', value: 340, max: 500, min: 1, step: 1 }
            },
            ...imgOption(),
            {
              type: Radio,
              option: {
                label: '是否展示副标题',
                name: 'showSubtitle',
                list: [{ name: '是', value: true }, { name: '否', value: false }],
                value: true
              }
            },
            {
              type: Input,
              option: {
                label: '展示数量',
                name: 'number',
                value: 1,
                type: 'number'
              }
            },
            ...resourcesOptions(),
            { type: Link, option: { label: '详情地址', name: 'link' }},
            ...moreLinkOps(),
            {
              type: Mapping,
              option: {
                label: '',
                name: 'mapping',
                list: [
                  { name: '封面', code: 'imgId', value: '' },
                  { name: 'oss封面', code: 'imgUrl', value: '' },
                  { name: '标题', code: 'title', value: '' },
                  { name: '副标题', code: 'subTitle', value: '' }
                ]
              }
            }
          ]
        },
        ...DataOption()
      ]
    }
  },
  /**
     * 横版卡片轮播1
     * @constructor
     */
  cardSwiperOne() {
    return {
      target: cardSwiperOne,
      parameter: {
        relate: false,
        mold: 'field',
        label: '横版卡片轮播1'
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            { type: Slider, option: { label: '左间距', name: 'spacing', value: 0, max: 100, step: 1 }},
            { type: Slider, option: { label: '右间距', name: 'paddingLeftRight', value: 0, max: 100, step: 1 }},
            ...cellTitleOps(),
            ...swiperNoIndicatorsOption(),
            ...sourceOption(),
            {
              type: Radio,
              option: {
                label: '是否循环',
                name: 'loop',
                list: [{ name: '是', value: true }, { name: '否', value: false }],
                value: true
              }
            },
            {
              type: Radio,
              option: {
                label: '是否显示副标题',
                name: 'showSubTitle',
                list: [{ name: '是', value: true }, { name: '否', value: false }],
                value: true
              }
            },
            {
              type: Slider,
              option: { label: '图片高度', name: 'imgHeight', value: 240, max: 500, min: 1, step: 1 }
            },
            ...imgOption(),
            { type: Link, option: { label: '详情地址', name: 'link' }},
            ...moreLinkOps(),
            ...resourcesOptions(),
            {
              type: Mapping,
              option: {
                label: '',
                name: 'mapping',
                list: [
                  { name: '封面', code: 'imgId', value: '' },
                  { name: 'oss封面', code: 'imgUrl', value: '' },
                  { name: '标题', code: 'title', value: '' },
                  { name: '副标题', code: 'subTitle', value: '' }
                ]
              }
            }
          ]
        },
        ...DataOption()
      ]
    }
  },
  /**
     * 横版卡片轮播2
     * @constructor
     */
  cardSwiperTwo() {
    return {
      target: cardSwiperTwo,
      parameter: {
        relate: true,
        mold: 'field',
        label: '横版卡片轮播2'
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            ...sourceOption(),
            { type: Slider, option: { label: '左右间距', name: 'paddingLeftRight', value: 0, max: 100, step: 1 }},
            {
              type: Switch,
              option: {
                label: '是否添加组件背景色',
                name: 'isLinearGradBg',
                value: false,
                activetext: '是',
                inactivetext: '否'
              }
            },
            ...bgImgColor(),
            ...cellTitleOps(),
            { type: UploadImage, option: { label: '标题背景图', name: 'titleImage' }},
            { type: Slider, option: { label: '标题背景高度', name: 'height', value: 40, max: 400, step: 1 }},
            { type: Slider, option: { label: '标题背景宽度', name: 'titleWidth', value: 150, max: 400, step: 1 }},
            { type: Slider, option: { label: '标题上间距', name: 'spacingTopB', value: 24, max: 100, step: 1 }},
            { type: Slider, option: { label: '轮播高度', name: 'lunboheight', value: 368, max: 1000, step: 1 }},
            { type: Slider, option: { label: '轮播上间距', name: 'spacingTop', value: 34, max: 100, step: 1 }},
            { type: Slider, option: { label: '轮播下间距', name: 'spacingBottom', value: 24, max: 100, step: 1 }},
            { type: Slider, option: { label: '轮播左右间距', name: 'spacing', value: 24, max: 100, step: 1 }},
            ...imgOption(),
            ...swiperOption(),
            {
              type: Input,
              option: {
                label: '展示数量',
                name: 'number',
                value: 1,
                type: 'number'
              }
            },
            {
              type: Radio,
              option: {
                label: '是否显示副标题',
                name: 'showSubTitle',
                list: [{ name: '是', value: true }, { name: '否', value: false }],
                value: true
              }
            },
            { type: Link, option: { label: '详情地址', name: 'link' }},
            {
              type: Select,
              option: {
                label: '资源类型',
                name: 'resource',
                list: [
                  { name: '活动', value: 'hd' },
                  { name: '人物（劳模工匠）', value: 'lmgj' },
                  { name: '人物（大师）', value: 'ds' },
                  { name: '人物（讲师）', value: 'js' },
                  { name: '视频课程', value: 'sp' },
                  { name: '新闻', value: 'xw' },
                  { name: '直播', value: 'zb' },
                  { name: '闯关', value: 'cg' },
                  { name: '专区', value: 'zq' },
                  { name: '图片', value: 'tp' }
                ],
                value: 'hd',
                override: function(ths, e) {
                  ths.$nextTick(() => {
                    for (let i = 0; i < ths.$parent.$parent.$children.length; i++) {
                      if (ths.$parent.$parent.$children[i].option.name === 'ActivityLabel') {
                        ths.$parent.$parent.$children[i].visible = e === 'hd'
                      }
                    }
                  })
                }
              }
            },
            ...labelOptions(),
            {
              type: Mapping,
              option: {
                label: '',
                name: 'mapping',
                list: [
                  { name: '封面', code: 'imgId', value: '' },
                  { name: 'oss封面', code: 'imgUrl', value: '' },
                  { name: '标题', code: 'title', value: '' },
                  { name: '副标题', code: 'subTitle', value: '' }
                ]
              }
            }
          ]
        },
        ...DataOption()
      ]
    }
  },
  /**
     * 卡片轮播3
     * @constructor
     */
  cardSwiperThree() {
    return {
      target: cardSwiperThree,
      parameter: {
        relate: true,
        mold: 'field',
        label: '卡片轮播3'
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            { type: Slider, option: { label: '左间距', name: 'spacing', value: 0, max: 100, step: 1 }},
            { type: Input, option: { label: '标题名称', name: 'title', required: true }},
            {
              type: Color,
              option: {
                label: '标题背景颜色',
                name: 'backgroundColor',
                value: 'rgba(255, 255, 255, 0)',
                showalpha: true
              }
            },
            { type: Slider, option: { label: '圆角大小', name: 'radiusSize', value: 20, max: 45, step: 1 }},
            {
              type: Radio,
              option: {
                label: '轮播方式',
                name: 'autoplay',
                list: [{ name: '手动', value: false }, { name: '自动', value: true }],
                value: true
              }
            },
            { type: Slider, option: { label: '轮播时长间隔（秒）', name: 'delay', value: 0, max: 60, step: 1 }},
            {
              type: Radio,
              option: {
                label: '是否循环',
                name: 'loop',
                list: [{ name: '是', value: true }, { name: '否', value: false }],
                value: true
              }
            },
            {
              type: Slider,
              option: { label: '图片高度', name: 'imgHeight', value: 310, max: 500, min: 1, step: 1 }
            },
            {
              type: Select,
              option: {
                label: '图片填充模式',
                name: 'imgType',
                list: [{ name: '填充满', value: 'fill' }, { name: '等比', value: 'contain' }],
                value: 'fill'
              }
            },
            {
              type: Input,
              option: {
                label: '展示数量',
                name: 'number',
                value: 1,
                type: 'number'
              }
            },
            { type: Link, option: { label: '详情地址', name: 'link' }},
            {
              type: Radio,
              option: {
                label: '查看更多展示',
                name: 'isMore',
                type: 'button',
                list: [{ name: '展示', value: '1' }, { name: '不展示', value: '2' }],
                layout: 'horizon',
                value: '1',
                override: function(ths, e) {
                  ths.$nextTick(() => {
                    for (let i = 0; i < ths.$parent.$parent.$children.length; i++) {
                      if (ths.$parent.$parent.$children[i].option.name === 'moreLink') {
                        ths.$parent.$parent.$children[i].visible = e === '1'
                      }
                    }
                  })
                }
              }
            },
            { type: Link, option: { label: '查看更多地址', name: 'moreLink' }},
            {
              type: Select,
              option: {
                label: '资源类型',
                name: 'resource',
                list: [
                  { name: '活动', value: 'hd' },
                  { name: '人物（劳模工匠）', value: 'lmgj' },
                  { name: '人物（大师）', value: 'ds' },
                  { name: '人物（讲师）', value: 'js' },
                  { name: '新闻', value: 'xw' },
                  { name: '直播', value: 'zb' },
                  { name: '闯关', value: 'cg' },
                  { name: '专区', value: 'zq' }
                ],
                value: 'hd',
                override: function(ths, e) {
                  ths.$nextTick(() => {
                    for (let i = 0; i < ths.$parent.$parent.$children.length; i++) {
                      if (ths.$parent.$parent.$children[i].option.name === 'ActivityLabel') {
                        ths.$parent.$parent.$children[i].visible = e === 'hd' || e === 'zb'
                      }
                    }
                  })
                }
              }
            },
            {
              type: Extend,
              option: {
                label: '标签',
                name: 'ActivityLabel',
                initalize: true,
                fields: [
                  {
                    type: Area,
                    option: {
                      label: '选择标签分类',
                      required: true,
                      name: 'type',
                      value: '',
                      async: '/backend/sysClassify/getClassifyTree',
                      asyncParams: {
                        classifyType: 'FLLX_BQ',
                        status: 'ZT01',
                        t: new Date().getTime()
                      },
                      props: {
                        children: 'children',
                        label: 'classifyName',
                        value: 'code',
                        checkStrictly: true
                      }
                    }
                  },
                  {
                    type: Select,
                    option: {
                      name: 'position',
                      label: '标签位置',
                      list: [
                        {
                          name: '默认',
                          value: 'default'
                        },
                        {
                          name: '左上',
                          value: 'topLeft'
                        },
                        {
                          name: '右上',
                          value: 'topRight'
                        }
                      ],
                      value: ''
                    }
                  },
                  { type: Input, option: { label: '标签标识', name: 'key' }}
                ]
              }
            },
            {
              type: Mapping,
              option: {
                label: '',
                name: 'mapping',
                list: [
                  { name: '封面', code: 'imgId', value: '' },
                  { name: 'oss封面', code: 'imgUrl', value: '' },
                  { name: '标题', code: 'title', value: '' }
                ]
              }
            }
          ]
        },
        ...DataOption()
      ]
    }
  },
  /**
     * 卡片轮播 1：1图文组件1
     * @constructor
     */
  cardSwiperTextImgOne() {
    return {
      target: cardSwiperTextImgOne,
      parameter: {
        relate: true,
        mold: 'field',
        label: '音频课程卡片轮播'
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            { type: Slider, option: { label: '左间距', name: 'spacing', value: 0, max: 100, step: 1 }},
            // { type: Input, option: { label: '标题名称', name: 'title', required: true }},
            ...cellTitleOps(),
            // {
            //   type: Color,
            //   option: {
            //     label: '标题背景颜色',
            //     name: 'backgroundColor',
            //     value: 'rgba(255, 255, 255, 0)',
            //     showalpha: true
            //   }
            // },
            { type: Slider, option: { label: '圆角大小', name: 'radiusSize', value: 20, max: 45, step: 1 }},
            {
              type: Radio,
              option: {
                label: '轮播方式',
                name: 'autoplay',
                list: [{ name: '手动', value: false }, { name: '自动', value: true }],
                value: false
              }
            },
            {
              type: Input,
              option: {
                label: '轮播时间间隔',
                name: 'delay',
                value: 0,
                type: 'number'
              }
            },
            // {
            //   type: Radio,
            //   option: {
            //     label: '是否循环',
            //     name: 'loop',
            //     list: [{ name: '是', value: true }, { name: '否', value: false }],
            //     value: true
            //   }
            // },
            // {
            //   type: Select,
            //   option: {
            //     label: '图片填充模式',
            //     name: 'imgType',
            //     list: [{ name: '填充满', value: 'fill' }, { name: '等比', value: 'contain' }],
            //     value: 'fill'
            //   }
            // },
            ...imgOption(),
            {
              type: Input,
              option: {
                label: '展示数量',
                name: 'number',
                value: 1,
                type: 'number'
              }
            },
            { type: Link, option: { label: '详情地址', name: 'link' }},
            // {
            //   type: Radio,
            //   option: {
            //     label: '查看更多展示',
            //     name: 'isMore',
            //     type: 'button',
            //     list: [{ name: '展示', value: '1' }, { name: '不展示', value: '2' }],
            //     layout: 'horizon',
            //     value: '1',
            //     override: function(ths, e) {
            //       // 11 12 13 14
            //       ths.$nextTick(() => {
            //         const lastIndex = ths.$parent.$parent.$children.length - 3
            //         ths.$parent.$parent.$children[lastIndex].visible = e === '1'
            //       })
            //     }
            //   }
            // },
            // { type: Link, option: { label: '查看更多地址', name: 'moreLink' }},
            ...moreLinkOps(),
            // {
            //   type: Select,
            //   option: {
            //     label: '资源类型',
            //     name: 'resource',
            //     list: [
            //       { name: '活动', value: 'hd' },
            //       { name: '人物（劳模工匠）', value: 'lmgj' },
            //       { name: '人物（大师）', value: 'ds' },
            //       { name: '人物（讲师）', value: 'js' },
            //       { name: '新闻', value: 'xw' },
            //       { name: '直播', value: 'zb' },
            //       { name: '闯关', value: 'cg' },
            //       { name: '专区', value: 'zq' },
            //       { name: '图片', value: 'tp' }
            //     ],
            //     value: 'hd'
            //   }
            // },
            {
              type: Mapping,
              option: {
                label: '',
                name: 'mapping',
                list: [
                  { name: '封面', code: 'imgId', value: '' },
                  { name: 'oss封面', code: 'imgUrl', value: '' },
                  { name: '标题', code: 'title', value: '' }
                ]
              }
            }
          ]
        },
        ...DataOption()
      ]
    }
  },
  /**
     * 音频课程列表（固定数量）
     * @constructor
     */
  cardSwiperTextImgTwo() {
    return {
      target: cardSwiperTextImgTwo,
      parameter: {
        relate: true,
        mold: 'field',
        label: '音频课程列表（固定数量）'
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            ...sourceOption(),
            { type: Slider, option: { label: '左右间距', name: 'spacing', value: 0, max: 100, step: 1 }},
            // { type: Input, option: { label: '标题名称', name: 'title', required: true }},
            ...cellTitleOps(),
            // {
            //   type: Color,
            //   option: {
            //     label: '标题背景颜色',
            //     name: 'backgroundColor',
            //     value: 'rgba(255, 255, 255, 1)',
            //     showalpha: true
            //   }
            // },
            // { type: Slider, option: { label: '圆角大小', name: 'radiusSize', value: 20, max: 45, step: 1 }},

            { type: Link, option: { label: '详情地址', name: 'link' }},
            // {
            //   type: Radio,
            //   option: {
            //     label: '查看更多展示',
            //     name: 'isMore',
            //     type: 'button',
            //     list: [
            //       { name: '展示', value: '1' },
            //       { name: '不展示', value: '2' }
            //     ],
            //     layout: 'horizon',
            //     value: '1',
            //     override: function(ths, e) {
            //       // 11 12 13 14
            //       ths.$nextTick(() => {
            //         const lastIndex = ths.$parent.$parent.$children.length - 1
            //         ths.$parent.$parent.$children[lastIndex].visible = e === '1'
            //       })
            //     }
            //   }
            // },
            // { type: Link, option: { label: '查看更多地址', name: 'moreLink' }}
            ...moreLinkOps()
          ]
        },
        ...DataOption()
      ]
    }
  }
}
